#include "soapH.h"
#include "soapStub.h"
#include "ChinaStockWebServiceSoap.nsmap"
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    struct soap clientSoap;
    struct _ns1__getStockInfoByCode getInfo;
    struct _ns1__getStockInfoByCodeResponse getInfoResponse;
    ns1__ArrayOfString *result;
    int size_num;
    int i=0;

    if (argc != 2) {
        cout << "arg num error" << endl;
        return -1;
    }

    soap_init(&clientSoap);

    getInfo.theStockCode = argv[1];

    if (soap_call___ns2__getStockInfoByCode(&clientSoap, NULL, NULL, &getInfo, &getInfoResponse) == SOAP_OK) {
        result = getInfoResponse.getStockInfoByCodeResult;
        size_num = result->__sizestring;
        for(i=0; i < size_num; i++) {
            cout << result->string[i] << endl;
        }
    } else {
        cout << "soap call error" << endl;
    }
    soap_destroy(&clientSoap);
    soap_end(&clientSoap);
    soap_done(&clientSoap); 
    return 0;
}
